package com.learnyou.server.xingzuo.dto.common;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

@Data
public class PageInfoDTO {
    @ApiModelProperty(value = "当前页大小")
    private long pageSize = 0l;
    @ApiModelProperty(value = "当前页")
    private long pageNum = 0l;
    @ApiModelProperty(value = "总页数")
    private long totalPage = 0l;
    @ApiModelProperty(value = "总数量")
    private long totalCount = 0l;


    public static PageInfoDTO build(long size, long current, long total){
        PageInfoDTO pageInfo = new PageInfoDTO();
        pageInfo.setPageNum(current);
        pageInfo.setPageSize(size);
        pageInfo.setTotalCount(total);
        pageInfo.setTotalPage((total + size - 1)/size);
        return pageInfo;
    }
}
